<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<isperp:grid url="sparepart/sparepart/listSparepartAllList" sortorder="desc" sortname="create_date"
	gridId="sptSearchGrid" ondbClickRowEvent="sptSearchGrid.view(rowid);"
	cusViewUrl="sparepart/sparepart/viewSptEdit" beforeDeleteAction="checkDelete(rowid)"
	cusDeleteUrl="sparepart/sparepart/old/delete">
	<jsp:attribute name="searchbar">
	<table class="search-table">
	<tbody>
		<tr>
			<td class="td1">编号：</td>
			<td class="td2"><input type="text" field="code" op="cn">
			</td>
			<td class="td1">描述：</td>
			<td class="td2"><input type="text" field="memo" op="cn">
			</td>
			<td class="td1">所属项目：</td>
			<td class="td2"><form:select path="projects" field="project_id"
							op="cn" data-allow-empty="true" items="${projects}"
							itemLabel="name" itemValue="id" cssClass="search" />
			</td>
		</tr>
		<tr>
			<td class="td1">创建人：</td>
			<td class="td2"><input type="text" field="creator_name" op="cn" />
			</td>
			<td class="td1">创建日期：</td>
			<td class="td2"><input id="createDateStart" type="date"
						field="create_date" op="gt" style="width: 68px" />~<input
						id="createDateEnd" type="date" field="create_date" op="lt"
						style="width: 68px" />
			</td>
			<td class="td1">类型：</td>
			<td class="td2">
			   <select id="sptType" field="spt_type" op="cn">
			   <option value=""></option>
			   <option value="备件采购">备件采购</option>
			   <option value="备件领用">备件领用</option>
			   <option value="备件归还">备件归还</option>
			   </select>
			</td>
		</tr>
	</tbody>
	</table>
	</jsp:attribute>
	<jsp:body>
	<isperp:column name="id" title="id" hidden="true">
	</isperp:column>
	<isperp:column name="code" title="编号" width="100">
	</isperp:column>
	<isperp:column name="memo" title="描述" width="180">
	</isperp:column>
	<isperp:column name="project_name" title="项目" width="120">
	</isperp:column>
	<isperp:column name="creator_name" title="创建人" width="120">
	</isperp:column>
	<isperp:column name="create_date" title="创建时间" width="140">
	</isperp:column>
	<isperp:column name="spt_type" title="类型" width="60">
	</isperp:column>
	<isperp:column name="status" title="状态" width="60">
	</isperp:column>
	</jsp:body>
</isperp:grid>
<script type="text/javascript">

function checkDelete(id)
{
  var curUserName='${curUserName}';
  var rowData = $("#sptSearchGrid").jqGrid('getRowData',id);
  if(rowData.status=="" || rowData.status=="新建" || curUserName=='admin')
  {
    return true;
  }else
  {
   isperp.alert("非草稿状态下的不能删除！");
  }
  
}
</script>